<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="todoList.css" />
</head>

<body>
    <div id="app">
        <div class="header">
            <div class="container">
                <div class="logo">toDoList</div>
                <div class="input-area">
                    <input type="text" v-model="title"> <button @click="add">添加</button>
                </div>
            </div>
        </div>
        <div class="container">
            <h2><span>正在进行</span> <span class="mask-num">1</span></h2>
            <ul class="mask-list">
                <li v-for="(item,index) in information" v-if="item.done===false">
                    <div><input type="checkbox" @change="change(index)" /> <span>{{item.title}}</span></div>
                    <button @click="del(index)">删除</button>
                </li>
            </ul>
        </div>
        <div class="container">
            <h2><span>已经完成</span> <span class="mask-num">1</span></h2>
            <ul class="mask-list complete-list">
                <li v-for="(item,index) in information" v-if="item.done===true">
                    <div><input type="checkbox" /> <span>{{item.title}}</span></div>
                    <button @click="del(index)">删除</button>
                </li>
            </ul>
        </div>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>

    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                title: "",
                information: []

            },
            methods: {
                add() {
                    this.information.unshift({
                        title: this.title,
                        done: false
                    })
                },
               
                change(index) {
                    this.information[index].done = true
                },
                del(index) {
                    this.information.splice(index, 1)
                }
            },
            
        })
    </script>
</body>

</html>